package com.coder4j.auth.entity;

import com.coder4j.enums.AuthRefTypeEnum;
import com.coder4j.starter.mybatis.BaseEntity;
import com.coder4j.starter.mybatis.annotation.TableAttribute;
import lombok.Data;
import lombok.NonNull;

/**
 * 权限_关系
 * @author keller
 * @date 2024-05-07 18:10:11
 */
@Data
@TableAttribute("auth_ref")
public class AuthRefEntity extends BaseEntity{

    /**
     * 类型
     */
    private String type;

    /**
     * 源ID
     */
    private Long sourceId;

    /**
     * 目标ID
     */
    private Long targetId;


    public static AuthRefEntity buildRef(@NonNull AuthRefTypeEnum typeEnum, Long sourceId, Long targetId) {
        AuthRefEntity entity = new AuthRefEntity();
        entity.setType(typeEnum.name());
        entity.setSourceId(sourceId);
        entity.setTargetId(targetId);
        return entity;
    }

}
